//
//  JJDefBlankView.m
//  MicroMall
//
//  Created by chenzm on 2020/5/4.
//  Copyright © 2020 XIN. All rights reserved.
//

#import "JJDefBlankView.h"

@interface JJDefBlankView()

@end

@implementation JJDefBlankView

#pragma mark - 赋值
-(void)setLabText:(NSString*)labText
          btnText:(NSString*)btnText
        imageText:(NSString*)imageText{
 

    
    self.lbl.numberOfLines=0;
    self.lbl.text=labText.length?labText:bDef_LblText;
    
    self.btn.layer.masksToBounds=YES;
    self.btn.layer.cornerRadius=17;
    [self.btn setTitleColor:kWhiteColor forState:UIControlStateNormal];
    self.btn.backgroundColor = kMainColor;
    
    self.btn.hidden = !btnText.length;
    [self.btn setTitle:btnText.length?btnText:bDef_BtnText forState:UIControlStateNormal];
    
    self.imgV.image = imageText.length?kImage(imageText):kImage(bDef_ImageText);
}


#pragma mark -Methods
-(void)clickBtnAction:(UIButton *)sender{
    !self.btnBlock?:self.btnBlock(sender);
}


-(void)dealloc{
    
}
#pragma mark - Intial
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder: aDecoder]) {
        [self setUpBaseData];
        [self setUpUI];
    }
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setUpBaseData];
        [self setUpUI];
    }
    return self;
}

///基本数据配置
-(void)setUpBaseData{
    
}

///控件添加
-(void)setUpUI{
    [self imgV];
    [self lbl];
    [self btn];
}


#pragma mark - lazyload
-(UIImageView *)imgV{
    if (!_imgV) {
        _imgV = [UIImageView new];
        _imgV.contentMode = UIViewContentModeScaleAspectFit;
        _imgV.layer.masksToBounds = YES;
        _imgV.userInteractionEnabled = YES;
        [self addSubview:_imgV];
        [_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self);
            make.centerY.mas_equalTo(self).offset(-50);
        }];
    }
    return _imgV;
}


-(UILabel *)lbl{
    if (!_lbl) {
        _lbl = [UILabel new];
        _lbl.textAlignment = NSTextAlignmentCenter;
        _lbl.textColor = kHexColor(0xB7B7B7);
        _lbl.font = kFont(14);
        [self addSubview:_lbl];
        [_lbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.imgV.mas_bottom).offset(15);
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
        }];
    }
    return _lbl;
}

-(UIButton *)btn{
    if (!_btn) {
        _btn = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn.titleLabel.font = kFont_13;
        [_btn setBackgroundColor:kMainColor forState:UIControlStateNormal];
        [_btn setTitleColor:kWhiteColor forState:UIControlStateNormal];
        _btn.hidden = YES;
        [self addSubview:_btn];
        [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.lbl.mas_bottom).offset(30);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(120);
            make.height.mas_equalTo(34);
        }];
        
        [_btn addTarget:self action:@selector(clickBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn;
}

@end
